<?php
namespace app\agent\controller;

use app\agent\service\UserAgentService;
use app\common\validate\UserAgentValidate;

/**
 * 代理商管理
 * @module 代理商管理
 * @controller 代理商
 */
class UserAgentController extends BaseController
{
    private $userAgent = null;

    private $validate = null;

	public function __construct()
	{
		parent::__construct();

		$this->userAgent = new UserAgentService();

		$this->validate = new UserAgentValidate();
	}

    /**
     * @action 代理商奖励转出到积分
     */
    public function zhuanchu()
    {
        $this->isPost();

        $request['uid'] = session('uid');

        $data = $this->userAgent->getZhuanchuView($request);

        $this->assign('data', $data);

        return $this->fetch();
	}

    protected function zhuanchupost()
    {
        $request        = input('post.');
        $request['uid'] = session('uid');

        $this->validate->goCheck($request, 'zhuanchupost');

        if( $this->userAgent->zhuanchu($request) === false )
        {
            $this->failure($this->userAgent->getError());
        }

        $this->render('转出成功', url('zhuanchu'));
	}
}